<?php

class NewsModule extends fvModule {

    function __construct () {
        $moduleName = strtolower(substr(__CLASS__, 0, -6));

        parent::__construct(fvSite::$fvConfig->get("modules.{$moduleName}.smarty.template"), 
                            fvSite::$fvConfig->get("modules.{$moduleName}.smarty.compile"), 
                            fvSite::$Layoult);
    }

    function showIndex() {
        $pager = new fvPager(PresscenterManager::getInstance());
        $this->__assign('Presscenters', $pager->paginate("type='news' and lang='".fvSite::$fvSession->get("lang")."'", "create_date DESC"));
        return $this->__display('news_list.tpl');    
    }

    function showEdit() {
        $request = fvRequest::getInstance();
        if (!$Presscenter = PresscenterManager::getInstance()->getByPk($request->getRequestParameter('id'))) {
            $Presscenter = new Presscenter();
        }
        $pager = new fvPager(PresscenterManager::getInstance());
        $editor = new fvCKEditor();
        fvCKFinder::SetupCKEditor( $editor, '/ckfinder/' ) ;
        $this->__assign(array(
            'Presscenter' => $Presscenter,
            //'editor' => $editor->editor("n[html]", "n_html", htmlspecialchars(stripslashes($Presscenter->html))),
            'editor' => $editor->editor("n[html]", "n_html", stripslashes($Presscenter->html)),
        ));
        return $this->__display('news_edit.tpl');
    }
   
}

?>
